<?php
    class Menu_Model extends CI_Model{
        
        function getMainAll(){
            $where = "PARENT_MENU IS NULL";
            $this->db->from('MENU');
            $this->db->where($where, NULL, false);
            $this->db->order_by('ID','asc');
            $results = $this->db->get()->result(); 


            return $results;
        }
        
        function getSubAll(){
            $where = "PARENT_MENU IS NOT NULL";
            $this->db->from('MENU');
            $this->db->where($where, NULL, false);
            $this->db->order_by('ID','asc');
            $results = $this->db->get()->result(); 

            return $results;
        }
        
        function getHomeMenu(){
            $where = "ID = 1";
            $this->db->from('MENU');
            $this->db->where($where, NULL, false);
            $results = $this->db->get()->result(); 

            return $results;
        }
        
        function getMenuAndSubMenuByID($menuID){
//            echo 'getMenuAndSubMenuByID';
            $this->db->from('MENU');
            $this->db->where('ID =', 1);
            $this->db->or_where('ID =', $menuID);
            $this->db->or_where('PARENT_MENU =', $menuID);
            
            $results = $this->db->get()->result(); 
                
//            foreach($results as $a){
//                echo $a->ID;
//            }
            
            return $results;
        }

    }

?>
